using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace GameFrameworkLibraly.Helpers.GeometryHelpers
{
    public class Polygon
    {
        public Polygon(IList<Point> vertexes)
        {
            Vertexes=new List<Point>(vertexes);
            Lines=new List<Line>();
            if (vertexes.Count > 1)
            {
                for (int i = 0; i < vertexes.Count-1; i++)
                {
                    Lines.Add(new Line(vertexes[i].ToVector2(),vertexes[i+1].ToVector2()));
                }
                Lines.Add(new Line(vertexes[vertexes.Count - 1].ToVector2(), vertexes[0].ToVector2()));
            }
        }

        public List<Line> Lines { get; private set; }
        public List<Point> Vertexes { get; private set; }



        public void Draw(SpriteBatch spriteBatch, Texture2D texture2D )
        {
            foreach (Point point in Vertexes)
            {
                spriteBatch.Draw(texture2D, new Rectangle(point.X - 1, point.Y - 1, 3, 3), null, Color.White);
            }
        }

    }
}
